﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using Entities;

namespace LoginP
{
    public static class LoginProcess
    {
        public static bool LoginOl(string tcKimlikNo, string sifre)
        {
            DAL.LoginDB loginDB = new DAL.LoginDB();
            DataRow loginKullanici = loginDB.KullaniciGetir(tcKimlikNo, sifre);
            if (loginKullanici != null)
            {
                LoginData loginData = new LoginData();
                loginData.AdiSoyadi = loginKullanici["AdiSoyadi"].ToString();
                loginData.KullaniciID = Convert.ToInt32(loginKullanici["Id"]);
                /*loginData.KurumAdi = loginKullanici["KurumAdi"].ToString();
                loginData.KurumID = Convert.ToInt32(loginKullanici["KurumID"].ToString());*/
                loginData.TcKimlikNo = loginKullanici["TcKimlikNo"].ToString();
                loginData.RolID = Convert.ToInt32(loginKullanici["RolID"].ToString());

                LoginP.LoginUser.Instance = loginData;
                LoginP.LoginUser.Online = true;

                return true;
            }
            else
                return false;
        }

        public static void LogOut()
        {
            LoginP.LoginUser.Online = false;
            LoginP.LoginUser.Instance = null;
            HttpContext.Current.Response.Redirect("Login.aspx");
        }
    }
}